<template>
  <div>
    <div v-for="item in list" :key="item.id">
      <div class="tupain2">
        <img class="tupain3" :src="item.avatar" alt="" />
        <div>
          <div class="wenzi" v-html="item.stem"></div>
          <div>
            <span>{{ item.creator }}</span
            >|<span>{{ item.createdAt }}</span>
          </div>
        </div>
      </div>
      <div v-html="item.content" class="wenzi"></div>
      <div>
        点赞{{ item.likeCount }}|<span>浏览{{ item.views }}</span>
      </div>
    </div>
  </div>
</template>

<script>
import axios from "axios";
export default {
  name: "TuiJian",
  data() {
    return {
      list: [],
    };
  },
  created() {
    console.log(this.$route.query.id);
    const id = this.$route.query.id;
    this.fn(id);
  },
  methods: {
    async fn(id) {
      const xxx = await axios({
        url: "http://interview-api-t.itheima.net/h5/interview/query",
        method: "get",
        headers: {
          Authorization: `Bearer ${id}`,
        },
      });
      this.list = xxx.data.data.rows;
    },
  },
};
</script>

<style>
.tupain2 {
  width: 100%;
  height: 50px;
  display: flex;
  align-items: center;
}

.tupain3 {
  width: 50px;
  height: 30px;
}
.wenzi {
  /* 文本超出两行省略号 */
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
}
</style>
